﻿!macro customInstall
  !insertmacro MUI_PAGE_LICENSE "$(LICENSE_FILE)"
  !insertmacro MUI_PAGE_DIRECTORY
  Page custom ShortcutPage ShortcutPageLeave
!macroend

Var Dialog
Var DesktopShortcut
Var DesktopShortcutState

Function ShortcutPage
  nsDialogs::Create 1018
  Pop $Dialog

  ${If} $Dialog == error
    Abort
  ${EndIf}

  ${NSD_CreateCheckBox} 20u 12u 100% 12u "创建桌面快捷方式"
  Pop $DesktopShortcut
  ${NSD_SetState} $DesktopShortcut 1  ; 默认勾选

  nsDialogs::Show
FunctionEnd

Function ShortcutPageLeave
  ${NSD_GetState} $DesktopShortcut $DesktopShortcutState
FunctionEnd

Function CreateShortcuts
  ${If} $DesktopShortcutState == 1
    CreateShortcut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_FILENAME}.exe"
  ${EndIf}
  CreateShortcut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_FILENAME}.exe"
FunctionEnd
